package org.linlinjava.litemall.wx.util;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;

import java.io.IOException;

public class HttpClientUtil {

    public static HttpResponse sendXMLDataByPost(String url, String xmlData) throws ClientProtocolException,IOException {
        HttpClient httpClient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        StringEntity entity = new StringEntity(xmlData);
        httpPost.setEntity(entity);
        httpPost.setHeader("Content-Type","text/xml;charset=UTF-8");
        HttpResponse response = httpClient.execute(httpPost);
        return response;
    }

}
